<?php

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class CreateCustomerDepartmentsTable extends Migration
{

    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('customer_departments', function (Blueprint $table) {
            $table->increments('id');
            $table->unsignedInteger('customer_id')->comment('所属医院/机构');
            $table->string('title')->comment('名称');
            $table->string('code')->unique()->comment('编号');
            $table->string('description')->nullable()->comment('描述');
            $table->string('phone')->nullable()->comment('电话');
            $table->string('email')->nullable()->comment('邮箱');
            $table->unsignedTinyInteger('state')->default(1)->comment('是否有效，0:无效,1:有效');
            $table->string('field')->nullable()->comment('专业领域(从字典选择)');
            $table->unsignedInteger('salesman')->nullable()->comment('所属销售');
            $table->unsignedInteger('region')->comment('所属大区');
            $table->unsignedInteger('province')->comment('所属省区');
            $table->unsignedInteger('rank')->nullable()->comment('显示顺序');
            $table->unsignedInteger('created_by')->comment('创建者');
            $table->unsignedInteger('updated_by')->comment('更新者');
            $table->string('data_scope')->nullable()->comment('数据域');
            $table->timestamps();

            $table->comment = '客户科室/部门表';
            $table->engine = 'InnoDB';
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('customer_departments');
    }

}
